import 'rxjs/add/operator/switchMap';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import {HttpClient} from "@angular/common/http";
import {HostService} from './host.service';

@Component({
  templateUrl: './host-list.component.html',
  styleUrls: [ './host.component.css' ]
})

export class HostListComponent implements OnInit {
  hosts: any;
  data : object;
  private selectedId: number;

  constructor(
    private hostService: HostService,
    private route: ActivatedRoute,
    private http: HttpClient
  ) {}

  ngOnInit() {
    this.gethosts();
  }
  gethosts(){
  this.hostService.gethosts().subscribe(data => {
    // data is now an instance of type ItemsResponse, so you can do this:
    this.hosts = data['results']
  });

  }
}
